<?php
class imagen extends objeto{
	var $id;
	function imagen($id){
		$this->id=$id;
	}
	function getProductos(){
		$q="select `p`.`nombre` as 'nombre',
				`p`.`id` as 'id',
				`p`.`descripcion` as 'descripcion',
				`p`.`precio` as 'precio',
				`f`.`path` as 'foto'
			from `productos` as `p`
				left join `imagenes_productos` as `ip` on `ip`.`producto`=`p`.`id`
				left join `fotos_productos` as `fp` on `fp`.`producto`=`p`.`id`
				left join `fotos` as `f` on `fp`.`foto`=`f`.`id`
			where `ip`.`imagen`='".mysql_real_escape_string($this->id)."'";
		$r=mysql_query($q);
		$prods=array();
		while($i=mysql_fetch_array($r,MYSQL_ASSOC)){
			$prods[]=$i;
		}
		return $prods;
	}
}
